package com.dja.nzw.mq.rabbit;

import com.dja.nzw.mq.rabbit.config.AMQPConfig;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;

/**
 * Created by shuyun on 2016/8/8.
 */
public abstract class EndPoint {
    public AMQPConfig amqpConfig;
    public CachingConnectionFactory connectionFactory;

    public EndPoint(AMQPConfig amqpConfig) {
        this.amqpConfig = amqpConfig;
        connectionFactory = new CachingConnectionFactory();
        connectionFactory.setAddresses(amqpConfig.getAddress());
        connectionFactory.setUsername(amqpConfig.getUsername());
        connectionFactory.setPassword(amqpConfig.getPassport());
        connectionFactory.setVirtualHost(amqpConfig.getVirtualhost());
        connectionFactory.setRequestedHeartBeat(amqpConfig.getRequestedHeartBeat());
        connectionFactory.setChannelCacheSize(amqpConfig.getConcurrentConsumers());
    }

}
